/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rockville.testing;

import com.rockville.filesystem.FileUtils;
import com.rockville.filesystem.ReadWriteTextFile;
import com.rockville.filesystem.RunTime;
import com.rockville.ufone.rssdata.RSSDataParser;

import java.io.File;
import org.apache.log4j.Logger;

/**
 *
 * @author Usman
 */
public class RunReadXml {

    public static final Logger log=Logger.getLogger(RunReadXml.class);
    
    private static String getLatestXmlIndexFile(String fqFilePathName) {
        //fqFilePathName = fqFilePathName.replaceAll("\\\\", "/");
        //if(!fqFilePathName.endsWith("/")) fqFilePathName = fqFilePathName +"/";
        
        //String command = "ls -t \""+ fqFilePathName +"*index.xml\" | head -1";
        String command = "dir /od /b \""+ fqFilePathName +"*index.xml\"";
        return RunTime.executeCommand( command );
    }
    
    private static String getHeadingFromXml (String fileContents) {
        String xmlHeading = "";
        int begIndex = 0;
        int endIndex = 0;
        
        try {
            begIndex = fileContents.indexOf("<HeadLine>");
            if(begIndex > -1) {
                fileContents = fileContents.substring(begIndex);

                begIndex = fileContents.indexOf(">")+1;
                if(begIndex > -1)
                    fileContents = fileContents.substring(begIndex);

                endIndex = fileContents.indexOf("</HeadLine>");

                xmlHeading = fileContents.substring( 0, endIndex);
            }
        }
        catch(Exception ex) {}
        
        return xmlHeading;
    }
    
    
}
